import Vue from 'vue'
import VueRouter from 'vue-router'


//1.注入插件
Vue.use(VueRouter)


//解决重复点击BUG
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


//2.定义路由
const routes = [
  {
    path: '/',
    redirect: '/home',

  },
  {
    path: '/home',
    component: () => import('@/views/Home')
  }
]

//3.创建路由实例
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
